Split index.js types into index.js.flow#49470
Closed
huntie wants to merge 1 commit into
Closed
Conversation
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D69659837 |
7405297 to
7657c2b
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D69659837 |
Summary:
Adds a `packages/react-native/index.js.flow` file.
**Motivation**
This is on the critical path to generating TypeScript types, and a full API snapshot, from `index.js.flow`.
As we iterate, this new file will move to closely matching `types/index.d.ts` by adding type exports (missing today) — giving us an equivalent public API in both languages.
**Motivation for this pattern**
Having a type index file:
- Will become the entry point for `yarn build-types`.
- Enables us to bypass the `module.exports` pattern in `index.js` without a runtime breaking change.
- This pattern is preferable because:
- 1/ Aligns with existing manual TypeScript definitions (i.e. these are **already restricted** to `import` syntax in user code)
- 2/ Allows doc comments on original types to propagate to IDEs/users.
**Implementation notes**
NOTE: This diff has **no effect** on compiled code at runtime, and **no effect** on the current manual TypeScript API of `react-native`. It only has an effect on Flow usage in fbsource — most of which are deep type imports today.
- Exports are grouped and sorted identically to each pre-existing getter in `index.js`.
Changelog: [Internal] - Redefine root `react-native` type exports, affecting Flow usages only
Reviewed By: rubennorte
Differential Revision: D69659837
7657c2b to
f017a66
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D69659837 |
Contributor
|
This pull request has been merged in cda2d11. |
Collaborator
|
This pull request was successfully merged by @huntie in cda2d11 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Adds a
packages/react-native/index.js.flowfile.Motivation
This is on the critical path to generating TypeScript types, and a full API snapshot, from
index.js.flow.As we iterate, this new file will move to closely matching
types/index.d.tsby adding type exports (missing today) — giving us an equivalent public API in both languages.Motivation for this pattern
Having a type index file:
yarn build-types.module.exportspattern inindex.jswithout a runtime breaking change.importsyntax in user code)Implementation notes
NOTE: This diff has no effect on compiled code at runtime, and no effect on the current manual TypeScript API of
react-native. It only has an effect on Flow usage in fbsource — most of which are deep type imports today.index.js.Changelog: [Internal] - Redefine root
react-nativetype exports, affecting Flow usages onlyDifferential Revision: D69659837